class Cart
  attr_reader :items

  def initialize
    @items = []
  end

  def add_product(product)

    current_item = @items.find {|item| item.product == product}
    if current_item
      current_item.increment_quantity
    else
      @items << CartItem.new(product)
    end
  end

  def total_price
    total_price = 0
    for item in @items do
      total_price += item.price
    end
    total_price
  end

end